package com.eastseeway.radioproject.RxLocation;

import com.amap.api.location.AMapLocationClientOption;

/**
 * Created by pitt on 2017/3/17.
 */

/**
 * ClientOption的工厂类
 */
public class ClientOptionFactory {

    /**
     * 创建一个包含默认的高德ClientOption的ClientOption
     *
     * @return A ClientOption
     */
    public ClientOption newDefaultAMapOption() {
        return createAMapOption(getAMapDefaultOption());
    }

    /**
     * 创建高德ClientOption的工厂方法
     *
     * @param option 高德地图的ClientOption 详情请查看{ http://wiki.lbsyun.baidu.com/cms/androidloc/doc/v7.1/index.html }
     * @return ClientOption
     */
    public ClientOption createAMapOption(final AMapLocationClientOption option) {
        return new ClientOption(option);
    }

    /**
     * @return Default AMapLocationClientOption
     * 详情请查看{ http://amappc.cn-hangzhou.oss-pub.aliyun-inc.com/lbs/static/unzip/Android_Location_Doc/index.html }
     */
    private AMapLocationClientOption getAMapDefaultOption() {
        final AMapLocationClientOption mOption = new AMapLocationClientOption();
        mOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);
        mOption.setGpsFirst(false);
        mOption.setHttpTimeOut(30000);
        mOption.setInterval(2000);
        mOption.setNeedAddress(true);
        mOption.setOnceLocation(false);
        mOption.setOnceLocationLatest(false);
        AMapLocationClientOption.setLocationProtocol(AMapLocationClientOption.AMapLocationProtocol.HTTP);
        mOption.setSensorEnable(false);
        mOption.setWifiScan(true);
        mOption.setLocationCacheEnable(true);
        return mOption;
    }

}
